home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Tools & Apps / Networking & Communications / Serial NB Sample Driver / Task / inc / read.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-15  |  2.6 KB  |  132 lines  |  [TEXT/MPS ]

  1. /********************************************************************************/
  2. /*                                                                                */
  3. /*        read.c - read request processing.                                        */
  4. /*                                                                                */
  5. /*        Richard W. Mincher.  February 19, 1990.                                    */
  6. /*                                                                                */
  7. /*        Copyright © 1990 Apple Computer, Inc.  All rights reserved.                */
  8. /*                                                                                */
  9. /********************************************************************************/
  10.  
  11. #include    "AROSE.h"
  12. #include    "os.h"
  13. #include    "managers.h"
  14.  
  15. #include    "ARDriver.h"
  16. #include    "ARTask.h"
  17.  
  18. ReadCall()
  19. {    
  20. #ifdef    DEBUG
  21.     printf("Read received.  mDataPtr = %x, mDataSize = %x\n",
  22.         msg->mDataPtr, msg->mDataSize );
  23. #endif    DEBUG
  24.  
  25.     G->readCmd = 1;
  26.  
  27.     msg->mNext = 0;
  28.     msg->mOData[0] = msg->mDataSize;
  29.     msg->mOData[1] = (unsigned long)(msg->mDataPtr);
  30.  
  31.     if (G->rxQHead)
  32.     {
  33.         G->rxQTail->mNext = msg;
  34.         G->rxQTail = msg;
  35.         return;
  36.     }
  37.     
  38.     G->rxQHead = msg;
  39.     G->rxQTail = msg;
  40.     TickleRead();
  41. }
  42.  
  43. TickleRead()
  44. {
  45.     short            s;
  46.     message            *m;
  47.     tid_type        temp;
  48.     short            count;
  49.  
  50.     while (G->rxQHead)
  51.     {
  52.         count = G->rxMax - G->rxCount;
  53.         if (!count)
  54.             break;
  55.         if (count > G->rxQHead->mOData[0])
  56.             count = G->rxQHead->mOData[0];
  57.  
  58.         if (count > (G->rxLast - G->rxOut))
  59.         {
  60.             NetCopy( G->rxQHead->mTo, G->rxOut,
  61.                 G->rxQHead->mFrom, (char *)(G->rxQHead->mOData[1]),
  62.                     G->rxLast - G->rxOut );
  63.             count -= G->rxLast - G->rxOut;
  64.             s = Spl(7);
  65.             G->rxCount += G->rxLast - G->rxOut;
  66.             G->sRxCount -= G->rxLast - G->rxOut;
  67.             (void)Spl(s);
  68.             G->rxQHead->mOData[0] -= G->rxLast - G->rxOut;
  69.             G->rxQHead->mOData[1] += G->rxLast - G->rxOut;
  70.             G->rxOut = G->rxFirst;
  71.         }
  72.         
  73.         NetCopy( G->rxQHead->mTo, G->rxOut,
  74.             G->rxQHead->mFrom, (char *)(G->rxQHead->mOData[1]),
  75.                 count);
  76.         s = Spl(7);
  77.         G->rxCount += count;
  78.         G->sRxCount -= count;
  79.         (void)Spl(s);
  80.         G->rxOut += count;
  81.         if (G->rxOut == G->rxLast)
  82.             G->rxOut = G->rxFirst;
  83.         G->rxQHead->mOData[0] -= count;
  84.         G->rxQHead->mOData[1] += count;
  85.                     
  86.         if (G->rxQHead->mOData[0] == 0)
  87.         {
  88.             m = G->rxQHead;
  89.             G->rxQHead = G->rxQHead->mNext;
  90.             temp = m->mTo;
  91.             m->mTo = m->mFrom;
  92.             m->mFrom = temp;
  93.             m->mCode |= 1;
  94.             Send( m );
  95.         }
  96.     }
  97.     
  98.     s = Spl(7);
  99.     count = G->rxMax - G->rxCount;
  100.     G->rxTickle = TICKLESIZE;
  101.     if (G->rxQHead)
  102.     {
  103.         if (G->rxQHead->mOData[0] < TICKLESIZE)
  104.             G->rxTickle = G->rxQHead->mOData[0] - count;
  105.     }
  106.     else
  107.         G->readCmd = 0;
  108.     (void)Spl(s);
  109.     
  110.     if (G->rxCount > RXSTART)
  111.     {
  112.         if (G->inSwHs && !(G->flowOff & 0x80))
  113.         {
  114.         }
  115.         if (G->inHwHs && !(G->flowOff & 0x40))
  116.         {
  117.             AssertDTR();
  118.         }
  119.     }
  120.  
  121.     if (G->rxCount < RXSTOP)
  122.     {
  123.         if (G->inSwHs && (G->flowOff & 0x80))
  124.         {
  125.         }
  126.         if (G->inHwHs && (G->flowOff & 0x40))
  127.         {
  128.             NegateDTR();
  129.         }
  130.     }    
  131. }
  132.